<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="post">
	Enter name <input type="text" id="nm" /> <br />
	Enter Email <input type="text" id="email" />
	<input type="button" value="Load" onclick="loadData()" />
	</form>
	<span id="data"></span>
</body>
<script type="text/javascript">
var req = new XMLHttpRequest();
loadData = function(){
	var userData = "nm=" + document.getElementById("nm").value
					+"&email=" + document.getElementById("email").value;
	req.onload = function(){
		document.getElementById("data").innerHTML = this.responseText;
		//alert(this.responseText);
	};
	req.open("post", "ajaxServlet", true);
	req.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	req.send(userData);
};
</script>
</html>